﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTOAuction;
using System.Data.Linq;
using System.Configuration;

namespace DAOAuction
{
	public class DAOSinhVien
	{
		/// <summary>
		/// author: hqlam
		/// </summary>
		public static SINHVIEN layThongTinSinhVien(int maSinhVien)
		{
			try
			{
				LinqDataContext db = new LinqDataContext(global::DAOAuction.Properties.Settings.Default.QUANLYGIAODUCConnectionString);
				return db.SINHVIENs.First(sv => sv.MASINHVIEN == maSinhVien);
			}
			catch
			{
				throw;
			}
		}

		//-----------------Thêm Sinh Viên Mới --------------------//
        public int themSinhVien(int maSinhVien, int maKhoa, int maKhoaHoc, string hoTen, int gioiTinh, DateTime ngaySinh, string noiSinh, string diaChi, string email, string soDienThoai, string matKhau, string tenDangNhap)
        {
            int intKetQua = 0;
            try
            {
                LinqDataContext db = new LinqDataContext(global::DAOAuction.Properties.Settings.Default.QUANLYGIAODUCConnectionString);
                db.SINHVIEN_add(maSinhVien, maKhoa, maKhoaHoc, hoTen, gioiTinh, ngaySinh, noiSinh, diaChi, email, soDienThoai, matKhau, tenDangNhap);
                intKetQua = 1;
            }
            catch (Exception ex)
            {
                intKetQua = 0;
            }
            return intKetQua;
        }
	}
}
